Plaster over difference between serial and usb timeouts.
authorrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 31 Jan 2006 16:45:17 +0000 (16:45 +0000)
committerrobertl <robertl@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Tue, 31 Jan 2006 16:45:17 +0000 (16:45 +0000)
gpsbabel/jeeps/gpsapp.c

index a77cd12ec38540724df0282b0278b9aed695823f..e428e895bfc22623fe05b82a57a2c5b0b1bc832a 100644 (file)
@@ -245,11 +245,18 @@ static int32 GPS_A000(const char *port)
         * discard all but the product inquiry response.  We have
         * no way of knowing how many we'll get, so we have to keep
         * reading until we incur a timeout.
+        * Worse still, the serial layer assumes a read timeout is a
+        * fatal error, while the USB layer (correctly) returns that error
+        * to the caller.  So we call GPS_Serial_Wait which spins into 
+        * a delay/select for the serial system and a NOP for USB.
         */
        for (i = 0; i < 25; i++) {
            rec->type = 0;
            
-           if (GPS_Packet_Read(fd, &rec) < 0) {
+           if(!GPS_Serial_Wait(fd))
+                   goto carry_on;
+
+           if (GPS_Packet_Read(fd, &rec) <= 0) {
                    goto carry_on;
            }
 
@@ -679,15 +686,11 @@ int32 GPS_A100_Get(const char *port, GPS_PWay **way, int (*cb)(int, GPS_PWay *))
     {
        if(!((*way)[i]=GPS_Way_New()))
            return MEMORY_ERROR;
-again: 
+
        if(!GPS_Packet_Read(fd, &rec))
            return gps_errno;
        if(!GPS_Send_Ack(fd, &tra, &rec))
            return gps_errno;
-/* Temp: just retry on read error. */
-       if (rec->n == 0) {
-               goto again;
-       }
 
        switch(gps_waypt_type)
        {